package GUILayer;

import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JProgressBar;
import javax.swing.JLabel;

public class LoadingWindow extends JFrame {

	private JPanel contentPane;
	private final JLabel lblL = new JLabel("Loading, please wait!");
	private JProgressBar progressBar;

	/**
	 * Create the frame.
	 */
	public LoadingWindow() {
		setTitle("Loading...");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(400, 350, 550, 400);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		contentPane.setLayout(new BorderLayout(0, 0));
		setContentPane(contentPane);
		
		progressBar = new JProgressBar(0, 100);
		progressBar.setStringPainted(true);
		contentPane.add(progressBar, BorderLayout.CENTER);
		contentPane.add(lblL, BorderLayout.NORTH);
	}
	
	public void showWindow()
	{
		progressBar.setValue(0);
		pack();
		setVisible(true);
	}
	
	public void closeWindow()
	{
		progressBar.setValue(100);
		setVisible(false);
	}
	
	public void setLoadingBarStatus(int status)
	{
		progressBar.setValue(status);
	}
}
